<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>歌手大赛票务系统</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/admin/css/font.css">
	<link rel="stylesheet" href="/admin/css/xadmin.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/Swiper/3.4.2/css/swiper.min.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/Swiper/3.4.2/js/swiper.jquery.min.js"></script>
    <script src="/admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/admin/js/xadmin.js"></script>

    <script type="text/javascript">
		// 重新生成验证码
		function reloadImg(){
			$('#img').attr('src','{:captcha_src()}?rand='+Math.random());
		}
		function dologin(){
			var username = $.trim($('#username').val());
			var num = $.trim($('#num').val());
			var pwd = $.trim($('#password').val());
			var verifycode = $.trim($('#verifycode').val());
			if(username == ''){
				layer.alert('请输入姓名',{icon:2});
				return;
			}
			if(num == ''){
				layer.alert('请输入学号',{icon:2});
				return;
			}
			if(pwd == ''){
				layer.alert('请输入密码',{icon:2});
				return;
			}
			if(verifycode==''){
				layer.alert('请输入验证码',{icon:2});
				return;
			}
			$.post('/admin/student/dologin',{'username':username,'num':num,'password':pwd,'verifycode':verifycode},function(res){
				if(res.code>0){
					reloadImg();
					layer.alert(res.msg,{icon:2});
				}else{
					layer.msg(res.msg);
					setTimeout(function(){window.location.href = '/admin/student/index'},1000);
				}
			},'json');
		}
    </script>

</head>
<body>
    <div class="login-logo"><h1>校园歌手大赛票务系统V0.1</h1></div>
    <div class="login-box">
        <form class="layui-form layui-form-pane" action="/admin/student/dologin" method="post">
              

            <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline">
                  <input type="text" name="username" lay-verify="required" placeholder="请输入你的姓名" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">学号</label>
                <div class="layui-input-inline">
                  <input type="text" name="num" lay-verify="number" placeholder="请输入你的学号" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-inline">
                  <input type="text" name="password" lay-verify="required" placeholder="请输入你的密码" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">验证码</label>
                <div class="layui-input-inline">
                    <input type="text" name="verifycode" id="verifycode" placeholder="请输入验证码" class="layui-input">
                </div>
                <img src="{:captcha_src()}" id="img" onclick="reloadImg()">
            </div>

            <div><center>
            <button class="btn btn-warning pull-right" lay-submit lay-filter="login"  type="submit">提交</button>
            </center>
            </div>
        </form>
    </div>
</body>
</html>